{include file="public/head"/} 
<style>
  #click{
    width:100%;
    height:100%;
    background-color: rgba(0,0,0,0.5);
    position:fixed;
    left: 0;
    top: 0;
    z-index: 1000;
    display: none;

  }
</style>
  <body>
    <div id="click" onclick="aa()" ></div>
    <div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">后台管理</a>
        <a href="">记录管理中心</a>
        <a><cite>家人开门记录</cite></a>
      </span>
      <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="javascript:location.reload()" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
    </div>
    <div class="x-body">
      <div class="layui-row">
        <form class="layui-form layui-col-md12 x-so"  method="get" action="#">
          <div class="layui-input-inline">
            <select name="devicekey" id="devicekey" lay-filter="devicekey">
              <option value="">门禁设备</option>
              {foreach $devicelist as $vol}
                <option value="{$vol.devicekey}" {if isset($devicekey)}{if $devicekey == $vol.devicekey}selected{/if}{/if}>{$vol.devicename}</option>
              {/foreach}
            </select>
          </div>
          <<div class="layui-input-inline">
            <select name="community_id" lay-filter="community_id" id="community_id">
              <option value="">所属小区</option>
              {foreach $communitylist as $name}
              <option value="{$name.id}" {if isset($community_id)}{if $community_id == $name.id}selected{/if}{/if}>{$name.name}</option>
              {/foreach}
            </select>
          </div>
          <div class="layui-input-inline">
            <select name="group" id="group" lay-filter="group">
              <option value="">组团</option>
              {if isset($groups)}
              {foreach $groups as $gro}
                <option value="{$gro}" {if isset($group)}{if $gro == $group}selected{/if}{/if}>{$gro}</option>
              {/foreach}
              {/if}
            </select>
          </div>
          <div class="layui-input-inline">
            <select name="building" id="building" lay-filter="building">
              <option value="">所属楼栋</option>
              {if isset($buildings)}
              {foreach $buildings as $build}
                <option value="{$build}" {if isset($building)}{if $build == $building}selected{/if}{/if}>{$build}幢</option>
              {/foreach}
              {/if}
            </select>
          </div>
          <div class="layui-input-inline">
            <select name="unit" id="unit"  lay-filter="unit">
              <option value="">所属单元</option>
              {if isset($units)}
              {foreach $units as $uni}
                <option value="{$uni}" {if isset($unit)}{if $uni == $unit}selected{/if}{/if}>{$uni}单元</option>
              {/foreach}
              {/if}
            </select>
          </div>
          <div class="layui-input-inline">
            <select name="room" id="room">
              <option value="">所属房间号</option>
              {if isset($rooms)}
              {foreach $rooms as $roo}
                <option value="{$roo}" {if isset($room)}{if $roo == $room}selected{/if}{/if}>{$roo}室</option>
              {/foreach}
              {/if}
            </select>
          </div>
         
          <input type="text" name="owner_name"  placeholder="姓名" autocomplete="off" class="layui-input" value="{if isset($owner_name)}{$owner_name}{/if}">
          <input type="text" name="phone"  placeholder="电话" autocomplete="off" class="layui-input" value="{if isset($phone)}{$phone}{/if}">

          <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
        </form>
      </div>
      <xblock>
        <span class="x-right" style="line-height:40px">共有数据：{$number} 条</span>
      </xblock>
      <table class="layui-table">
        <thead>
          <tr>
            <th></th>
            <td>小区</td>
            <th>门禁设备</th>
            <th>门牌号</th>
            
            <th>姓名</th>
            <th>手机号</th>
            <th>开门方式</th>

            <th>开门时间</th>
            <th>人脸抓拍</th>
          </tr>
        </thead>
        <tbody>
          {foreach $list as $lis}
          <tr style="height:55px">
            <td>{$lis.id}</td>
            <td>{$lis.community_name}</td>
            <td>{$lis.devicename}</td>
            <td>{$lis.group}-{$lis.building}-{$lis.unit}-{$lis.room}</td>
           
            <td>{$lis.name}</td>
            <td>{$lis.phone}</td>
            <td>
                {if $lis.recMode=="1"}
                刷脸
               {elseif $lis.recMode=="2"}
               刷卡
               {elseif $lis.recMode=="3"}
               双重认证
               {elseif $lis.recMode=="4"}
               人证比对
               {/if}
           </td>

            <td>{$lis.showTime|date="Y-m-d H:i:s"}</td>
            <td>
              {if $lis.recMode=="1"}
                <img src="{$lis.photoUrl}" onclick='mag("{$lis.photoUrl}")' style="width:40px;height:50px"/>
              {/if}
            </td>
          </tr>
          {/foreach}
        </tbody>
      </table>
      <div class="page">
        <div>
            {$recordlist->render()}
        </div>
      </div>

    </div>
    <script>
      let a = document.getElementById("click")
      function mag(url){
          // console.log(123)

          a.style = "display:inline-block;"
          let b = `<img src="`+url+`" style="margin-left:20%;text-align:center">`
          a.innerHTML=b
      }
      function aa() {
          a.style = "display:none;"
      }
    </script>
     <script>
        layui.use(['form'], function() {
            var form = layui.form
            form.on('select(community_id)', function(f){
                var url = "{:url('room/fetchdata')}"
                $.post(url, {community_id: f.value, type: 1}, function(data) {
                    $('#group').html("")
                    var option = "<option value=''>所有组团</option>"
                    $('#group').append(option)
                    for (var i = 0; i < data.length; i++) {
                    option = "<option value='" + data[i] + "'>" + data[i] + "</option>"
                    $('#group').append(option)
                    }
                    
                    form.render('select')
                })
                
                $('#community_id').data('community_id', f.value)
            })

            form.on('select(group)', function(f){
                var data_community = $('#community_id').data('community_id')
                var get_community = "<?php if (isset($community_id)) { echo $community_id;}?>"
                var community_id = typeof data_community === 'undefined' ? get_community : data_community
                var url = "{:url('room/fetchdata')}"
                $.post(url, {community_id: community_id, group: f.value, type: 2}, function(data) {
                    $('#building').html("")
                    var option = "<option value=''>所有楼栋</option>"
                    $('#building').append(option)
                    for (var i = 0; i < data.length; i++) {
                        option = "<option value='" + data[i] + "'>" + data[i] + "</option>"
                        $('#building').append(option)
                    }
                    $('#group').data('group', f.value)
                    form.render('select')
                })
            })
    
            form.on('select(building)', function(f){
                var data_community = $('#community_id').data('community_id')
                var get_community = "<?php if (isset($community_id)) { echo $community_id;}?>"
                var community_id = typeof data_community === 'undefined' ? get_community : data_community

                var data_group = $('#group').data('group')
                var get_group = "<?php if (isset($group)) { echo $group;}?>"
                var group = typeof data_group === 'undefined' ? get_group : data_group

                var url = "{:url('room/fetchdata')}"
                $.post(url, {building: f.value, community_id: community_id, group: group, type: 3}, function(data) {
                $('#unit').html("")
                var option = "<option value=''>所有单元</option>"
                $('#unit').append(option)
                for (var i = 0; i < data.length; i++) {
                    option = "<option value='" + data[i] + "'>" + data[i] + "</option>"
                    $('#unit').append(option)
                }
                $('#building').data('building', f.value)
                form.render('select')
                })
            })
    
            form.on('select(unit)', function(f){
                var data_community = $('#community_id').data('community_id')
                var get_community = "<?php if (isset($community_id)) { echo $community_id;}?>"
                var community_id = typeof data_community === 'undefined' ? get_community : data_community

                var data_group = $('#group').data('group')
                var get_group = "<?php if (isset($group)) { echo $group;}?>"
                var group = typeof data_group === 'undefined' ? get_group : data_group

                var data_building = $('#building').data('building')
                var get_building = "<?php if (isset($building)) { echo $building;}?>"
                var building = typeof data_building === 'undefined' ? get_building : data_building
        
                var url = "{:url('room/fetchdata')}"
                $.post(url, {unit: f.value, community_id: community_id, group: group, building: building, type: 4}, function(data) {
                $('#room').html("")
                var option = "<option value=''>所有房间</option>"
                $('#room').append(option)
                for (var i = 0; i < data.length; i++) {
                    option = "<option value='" + data[i] + "'>" + data[i] + "</option>"
                    $('#room').append(option)
                }
                $('#unit').data('unit', f.value)
                form.render('select')
                })
            })
    
        })
    </script>
    <script>
      var _hmt = _hmt || []; (function() {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
      })();
    </script>
  </body>

</html>